78A - Haiku - CodeForces Solution


implementation strings *800

Please click on ads to support us..

Python Code:

def f(s):
    st = {"a", "e", "i", "o", "u"}
    d = 0
    for c in s:
        if(c in st):
            d += 1
    return d
print(("NO","YES")[f(input()) == 5 and f(input()) == 7 and f(input()) == 5])
                    

C++ Code:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// brute force?
map<char,int> m={{'a',1},{'e',1}
,{'i',1},{'o',1},{'u',1}};
vector<int> v={5,7,5};
int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
//    freopen("input.txt","r", stdin);
    int idx=0;
    for(string line; getline(cin, line);){
        int sum=0;
        for(char c:line){
            if (m.count(c)) sum++;
        }
        if (sum!=v[idx]) {
            cout << "NO"<<endl;
            return 0;
        }
        idx++;
    }
    cout << "YES"<<endl;

}






Comments

Submit
0 Comments
More Questions

749A - Bachgold Problem
1486B - Eastern Exhibition
1363A - Odd Selection
131B - Opposites Attract
490C - Hacking Cypher
158B - Taxi
41C - Email address
1373D - Maximum Sum on Even Positions
1574C - Slay the Dragon
621A - Wet Shark and Odd and Even
1395A - Boboniu Likes to Color Balls
1637C - Andrew and Stones
1334B - Middle Class
260C - Balls and Boxes
1554A - Cherry
11B - Jumping Jack
716A - Crazy Computer
644A - Parliament of Berland
1657C - Bracket Sequence Deletion
1657B - XY Sequence
1009A - Game Shopping
1657A - Integer Moves
230B - T-primes
630A - Again Twenty Five
1234D - Distinct Characters Queries
1183A - Nearest Interesting Number
1009E - Intercity Travelling
1637B - MEX and Array
224A - Parallelepiped
964A - Splits